/*
 * File: Target.java
 * Name: Diego A. Falciola
 * Section Leader: Sam King 
 * -----------------
 * This file is the starter file for the Target problem.
 */

import acm.graphics.*;
import acm.program.*;
import java.awt.*;

public class Target extends GraphicsProgram {

	// Number of pixels per inch
	private static final double PIXELS_PER_INCH = 72;
	// Big circle radio size
	private static final double CIRCLE_ONE_RADIUS = 1*PIXELS_PER_INCH;
	// Medium circle radio size
    private static final double CIRCLE_TWO_RADIUS = 0.65*PIXELS_PER_INCH;
	// Small circle radio size
    private static final double CIRCLE_THREE_RADIUS = 0.3*PIXELS_PER_INCH;    
    
    /**
     * Draw a target at the center of the screen
     */
	public void run() {
		// find the center 
		GPoint middlePoint = getMiddlePoint();
		
		// and draw target
		drawCircleAtCenter(middlePoint, CIRCLE_ONE_RADIUS, Color.RED);
		drawCircleAtCenter(middlePoint, CIRCLE_TWO_RADIUS, Color.WHITE);
		drawCircleAtCenter(middlePoint, CIRCLE_THREE_RADIUS, Color.RED);
	}
	
	/**
	 * Draw a centered circle 
	 * @param center center of the circle
	 * @param radius radius of the circle
	 * @param color color of the circle
	 */
	private void drawCircleAtCenter(GPoint center, double radius, Color color){
		// Does not start from center, but from upper left corner
		// which needs to be calculated 
		
		double startX = center.getX()-radius;
		double startY = center.getY()-radius;
		double diameter = radius*2;
		
		GOval oval = new GOval(startX, startY, diameter, diameter);
		oval.setFillColor(color);
		oval.setFilled(true);
		add(oval);
	}
	
	/**
	 * Get the middle point of the screen
	 * @return middle point of the screen
	 */
	private GPoint getMiddlePoint(){
		return new GPoint(getWidth()/2, getHeight()/2);
	}
}
